/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocios;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;

/**
 *
 * @author Rafaely
 */
public class Conexão {

    public static java.sql.Connection conexãoJDBC;
    public Statement st;
    public ResultSet rs;

    public static void Conectar(String usuario, String senha)
            throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        conexãoJDBC = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");

    }

    public static void Desconectar() throws SQLException {
        conexãoJDBC.close();
    }

    public void executaSQL(String sql){

		try{
			st = conexãoJDBC.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
			rs = st.executeQuery(sql);
		}
		catch(SQLException ex)
		{
			JOptionPane.showMessageDialog(null, ex.getMessage());
		}

	}

}

    
    

